#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->pushButton_4,SIGNAL(pressed()),this,SLOT(func()));
    connect(ui->blueButton,SIGNAL(pressed()),ui->B,SLOT(clear()));
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    qDebug() << "clicked";
}

void MainWindow::on_pushButton_2_released()
{
    qDebug() << "released";
    ui->pushButton_2->setText("pressed");
}

void MainWindow::on_pushButton_2_pressed()
{
    qDebug() << "pressed";
    ui->pushButton_2->setText("released");
}

void MainWindow::on_pushButton_3_clicked(bool checked)
{
    if(checked)
    {
        ui->pushButton_3->setText("close");
    } else {
        ui->pushButton_3->setText("open");
    }

    checked = !checked;
}

void MainWindow::func()
{
    qDebug() << "func";
}

void MainWindow::on_okBtn_clicked()
{
    QString r = ui->R->text();
    QString g = ui->G->text();
    QString b = ui ->B->text();

    if(r>=0 && r<=255 && g>=0 && g<=255 && b>=0 && b<=255)
    {
        QString cmd = QString("MainWindow{background-color: rgb(%1,%2,%3)}").arg(r).arg(g).arg(b);
        this->setStyleSheet(cmd);
    }
}

void MainWindow::on_pushButton_5_clicked()
{

}
